package com.demo.quartz;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

public class HelloJob implements Job {
    private String message;
    private Float FloatJobValue;
    private Double DoubleTriggerValue;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        // 实现业务逻辑，相当于run
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(date));
//        System.out.println("Hello World!");
        JobKey key = jobExecutionContext.getJobDetail().getKey();
        System.out.println("My Job name and group are " + key.getName() + ":" +
                key.getGroup());
        TriggerKey trKey = jobExecutionContext.getTrigger().getKey();
        System.out.println("My Trigger name and group are " + trKey.getName() + ":" +
                trKey.getGroup());
//        JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap();
//        JobDataMap tdataMap = jobExecutionContext.getTrigger().getJobDataMap();
//        JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();
//        String jogMsg = dataMap.getString("message");
//        Float jobFloatValue = dataMap.getFloatValue("FloatJobValue");
        System.out.println(message);
        System.out.println(FloatJobValue + "," +DoubleTriggerValue);
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Float getFloatJobValue() {
        return FloatJobValue;
    }

    public void setFloatJobValue(Float floatJobValue) {
        FloatJobValue = floatJobValue;
    }

    public Double getDoubleTriggerValue() {
        return DoubleTriggerValue;
    }

    public void setDoubleTriggerValue(Double doubleTriggerValue) {
        DoubleTriggerValue = doubleTriggerValue;
    }
}
